import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;

public class Server {

	private static final int SERVER_PORT = 8080;
	private OutputChanels outs = new OutputChanels();

	private void init() throws IOException {
		ServerSocket serverSocket = new ServerSocket(SERVER_PORT);
		try {
			while (true) {
				Socket socket = serverSocket.accept();
				new DealWithClient(outs, socket).start();
			}
		} finally {
			serverSocket.close();
		}
	}

	public static void main(String[] args) {
		try {
			new Server().init();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
